package com.lingxu.base.system.manage.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lingxu.base.system.manage.entity.SysRole;
import com.lingxu.base.system.manage.entity.SysUser;
import com.lingxu.base.system.manage.entity.SysUserRoleQueryVo;
import com.lingxu.base.system.manage.mapper.SysRoleMapper;
import com.lingxu.base.system.manage.mapper.SysRoleMenuMapper;
import com.lingxu.base.system.manage.mapper.SysUserRoleMapper;
import com.lingxu.base.system.manage.model.SysRoleTree;
import com.lingxu.base.system.manage.service.ISysRoleMenuService;
import com.lingxu.base.system.manage.service.ISysRoleService;
import com.lingxu.base.system.manage.service.ISysUserRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

/**
 * @Description: 角色信息
 * @Author: LingXu
 * @Date:   2021-01-04
 * @Version: V1.0.1
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {

     @Resource
     private SysRoleMapper sysRoleMapper;

     @Resource
     private SysRoleMenuMapper sysRoleMenuMapper;
     @Resource
     private SysUserRoleMapper sysUserRoleMapper;

     @Resource
     private ISysRoleMenuService sysRoleMenuService;
     
     @Resource
     private ISysUserRoleService sysUserRoleService;


    /**
     * 角色信息-列表查询
     * @return 角色信息列表
     */
    @Override
    public List<SysRole> queryList(){
        return sysRoleMapper.queryList();
    }

    @Override
    public List<SysRole> getUserRoleList(String userId,Integer flag) {
        return sysRoleMapper.getUserRoleList(userId,flag);
    }


    /**
     * 角色信息-角色名集合查询
     * @param userName 用户名
     * @return 角色名集合,角色code集合，角色列表
     */
    @Override
    public Set<String> getCodeSetByUserName(String userName) {
        return sysRoleMapper.getCodeSetByUserName(userName);
    }
    @Override
    public List<SysRole> getIdNameCodeByUserName(String userName) {
        return sysRoleMapper.getIdNameCodeByUserName(userName);
    }

    @Override
    public List<SysRoleTree> getTreeListByUserIdInManage(String userId, String rootTableType, String orgId) {
        return this.baseMapper.getTreeListByUserIdInManage(userId,rootTableType,orgId);
    }

    @Override
    public IPage<SysUser> getSysUserByRole(Page<SysUser> page, SysUserRoleQueryVo vo) {
        return sysUserRoleMapper.getSysUserByRole(page,vo);
    }


}
